<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="mvc.domain.Student"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../js/jquery-2.1.4.js"></script>
<script type="text/javascript">
	$(function() {
		$('a[href*=delete]').click(function() {
			var content = $(this).parent().parent().find('td:eq(0)').text();
			var flag = confirm('确定要删除' + content + '的信息么');
			return flag;
		});
	});
</script>
<title>Student</title>
</head>
<body>
	<form action="queryAll.do" method="post">
		<table>
			<tr>
				<td>Student Name</td>
				<td><input type="text" name="name" /></td>
			</tr>
			<tr>
				<td>Student Gender</td>
				<td><input type="text" name="gender" /></td>
			</tr>
			<tr>
				<td><input type="submit" value="Query" /></td>
				<td><a href="add.jsp">Create New Student</a></td>
			</tr>
		</table>
	</form>

	<br />
	<br />
	<%
		@SuppressWarnings("unchecked")
		List<Student> students = (List<Student>) request.getAttribute("students");
		if (students != null && students.size() > 0) {
	%>
	<br />
	<br />
	<hr />
	<br />
	<br />
	<table border="1" cellpadding="10" cellspacing="0">
		<tr>
			<th>Name</th>
			<th>Age</th>
			<th>Gender</th>
			<th>Birthday</th>
			<th>Update</th>
			<th>Delete</th>
		</tr>
		<%
			for (int i = 0; i < students.size(); i++) {
					Student student = students.get(i);
		%>
		<tr>
			<td><%=student.getName()%></td>
			<td><%=student.getAge()%></td>
			<td><%=student.getGender()%></td>
			<td><%=student.getBirthday()%></td>
			<td><a href="edit.do?id=<%=student.getId()%>">Update</a></td>
			<td><a href="delete.do?id=<%=student.getId()%>">Delete</a></td>
		</tr>
		<%
			}
		%>
	</table>
	<%
		}
	%>
</body>
</html>